package com.qingkai.onlineshop.data.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Transaction
import com.qingkai.onlineshop.data.entity.ItemEntity
import com.qingkai.onlineshop.data.relations.ItemFull
import com.qingkai.onlineshop.data.relations.ItemWithPics

@Dao
interface ItemDao {
    @Insert
    suspend fun insertAll(items: List<ItemEntity>)

    @Transaction
    @Query("SELECT * FROM item")
    suspend fun getItemsWithPics(): List<ItemWithPics>

    @Transaction
    @Query("SELECT * FROM item WHERE showRecommended = 1")
    suspend fun getRecommendedItems(): List<ItemWithPics>

    @Transaction
    @Query("SELECT * FROM item WHERE categoryId = :categoryId")
    suspend fun getItemsByCategory(categoryId: Int): List<ItemWithPics>

    @Transaction
    @Query("SELECT * FROM item")
    suspend fun getFullItemData(): List<ItemFull>
}